package BinaryOperators;

public class MinFunction implements Function{

	@Override
	public double Execute(double[] args) {
		if(args.length == 0){
			//TODO handle Exception:
			throw new IndexOutOfBoundsException();
		}else if(args.length == 1){
			return args[0];
		}else{
			double result = Math.min(args[0],args[1]);
			for (int i=2; i<args.length; i++){
				if(Math.min(args[i-1], args[i])<result){
					result = Math.min(args[i-1], args[i]);
				}
			}
		return result;
		}
		
		}

}